<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Order extends Model
{
    protected $table = 'order';
    
    /**
     * 是否主动维护时间戳
     *
     * @var bool
     */
    public $timestamps = false;
    
    static public function orderSucc($order){
        $order->finishtime = time();
        $order->status = 2;
        $order->save();
        Order::orderNotify($order);
    }
    
    static public function orderFail($order,$reason = ''){
        $order->finishtime = time();
        $order->status = -1;
        $order->reset = 0;
        if ($reason) $order->reason = $reason;
        $order->save();
        $pay = new \WxPay(Set::getSet('wxpay'));
        $res = $pay->refund($order->transid,$order->price,$reason);
        if ($res['code'] == 1){
            $order->refundid = $res['transid'];
            $order->save();
        }
        return $res;
    }
    
    static public function orderNotify($order){
        
    }
}
